package com.etc;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ImageController {

    @Autowired
    OkHttpCli client;
    
    /**
     * 图片外链请求
     * @return
     */
    @PostMapping
    public String saveonserver(@RequestBody Map map) {
        String url = "";
        if (map.get("data") != null) {
            try {
                url = client.upload(String.valueOf(map.get("imageType")), (byte[]) map.get("data"));
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return "服务器异常";
            }
        }
        return url;
    }
}
